package org.istt.domain;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * AttachFile entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "TBL_ATTACH_FILE", schema = "dbo", catalog = "onegate", uniqueConstraints=@UniqueConstraint(columnNames={"CATEGORY_ID", "CATEGORY_TYPE_ID", "DOCUMENT_TYPE_ID", "ATTACH_FILE_NAME"}))
public class AttachFile extends BaseObject<Long> implements
		java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -4590485352315554896L;
	private Long id;
	private Category category;
	private CategoryType categoryType;
	private DocumentType documentType;
	private String attachFileName;
	private Long numberOfCopy;
	private Integer position;
	private Boolean heading;

	// Constructors

	/** default constructor */
	public AttachFile() {
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CATEGORY_ID")
	public Category getCategory() {
		return this.category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CATEGORY_TYPE_ID")
	public CategoryType getCategoryType() {
		return categoryType;
	}

	public void setCategoryType(CategoryType categoryType) {
		this.categoryType = categoryType;
	}

	@Column(name = "ATTACH_FILE_NAME", nullable=false)
	public String getAttachFileName() {
		return this.attachFileName;
	}

	public void setAttachFileName(String attachFileName) {
		this.attachFileName = attachFileName;
	}
	
	@Column(name="NUMBER_OF_COPY")
	public Long getNumberOfCopy() {
		return numberOfCopy;
	}

	public void setNumberOfCopy(Long numberOfCopy) {
		this.numberOfCopy = numberOfCopy;
	}

	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof AttachFile)) return false;

		final AttachFile ps = (AttachFile) o;


        if (!getAttachFileName().equals(ps.getAttachFileName())) return false;

		return true;
	}

	public int hashCode() {
		int result;
		result = attachFileName.hashCode();
		result = 29 * result;
		return result;
	}
	
	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
        .append("attachFileName", this.attachFileName);

		return sb.toString();
	}

	public void setDocumentType(DocumentType documentType) {
		this.documentType = documentType;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "DOCUMENT_TYPE_ID")
	public DocumentType getDocumentType() {
		return documentType;
	}

	public void setPosition(Integer position) {
		this.position = position;
	}

	@Column(name = "POSITION")
	public Integer getPosition() {
		return position;
	}

	public void setHeading(Boolean heading) {
		this.heading = heading;
	}

	@Column(name = "HEADING")
	public Boolean getHeading() {
		return heading;
	}

}